package cn.edu.tsinghua.smxq.mobilecity.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import cn.edu.tsinghua.smxq.mobilecity.po.FoodPrice;
import cn.edu.tsinghua.smxq.mobilecity.utils.DBUtils;

public class FoodPriceDAO {

	public boolean create(FoodPrice foodPrice) throws SQLException {
		boolean success = false;
		Connection conn = DBUtils.Connect();
		PreparedStatement pstmt = conn
				.prepareStatement("INSERT INTO mobilecity.foodprice(cityid,foodid,price,time) values(?,?,?,?)");
		pstmt.setInt(1, foodPrice.getCityId());
		pstmt.setInt(2, foodPrice.getFoodId());
		pstmt.setFloat(3, foodPrice.getPrice());
		pstmt.setDate(4, foodPrice.getTime());
	
		if (pstmt.executeUpdate() == 1) {
			success = true;
		}
		pstmt.close();
		conn.close();
		return success;
	}
}
